package com.apidoc.config;

import com.apidoc.core.ApiDocGenerator;
import com.apidoc.core.ApiDocScanner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置类
 */
@Configuration
@EnableConfigurationProperties(ApiDocProperties.class)
public class ApiDocAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public ApiDocScanner apiDocScanner(ApiDocProperties properties) {
        return new ApiDocScanner(properties);
    }

    @Bean
    @ConditionalOnMissingBean
    public ApiDocGenerator apiDocGenerator(ApiDocScanner scanner, ApiDocProperties properties) {
        return new ApiDocGenerator(scanner, properties);
    }
}
